//
//  JOStatusCell.m
//  新浪微博模拟
//
//  Created by song on 15/7/19.
//  Copyright (c) 2015年 song. All rights reserved.
//

#import "JOStatusCell.h"
#import "JOStatus.h"
#import "JOStatusFrame.h"
#import "JOUser.h"

#define JOStatusNameFont [UIFont systemFontOfSize:15]

@interface JOStatusCell()



//顶部的view
@property(nonatomic, weak) UIImageView *topview;
//头像
@property(nonatomic, weak) UIImageView *iconview;

@property(nonatomic, weak) UIImageView *vipview;

@property(nonatomic, weak) UIImageView *photoview;
// 名字
@property(nonatomic, weak) UILabel *nameLable;
//时间
@property(nonatomic, weak) UILabel *timeLable;

@property(nonatomic, weak) UILabel *sourceLable;

@property(nonatomic, weak) UILabel *contentLable;


@property(nonatomic, weak) UIImageView *retweetView;

@property(nonatomic, weak) UILabel *retweetNameLabel;
// 名字
@property(nonatomic, weak) UILabel *retweetContentLabel;
//时间
@property(nonatomic, weak) UIImageView *retweetPhotoView;

@end


@implementation JOStatusCell


+(id)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID=@"HomeCell";
    JOStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil)
    {
        cell = [[JOStatusCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    return cell;
    
}



-(void)setStatusFrame:(JOStatusFrame *)statusFrame
{
    _statusFrame = statusFrame;
    [self setOriginalData];
    
    
}


-(void)setOriginalData
{
    
    JOStatus *status = self.statusFrame.status;
    JOUser *user = status.user;
    self.topview.frame =self.statusFrame.topviewF;
    
    [self.iconview setImage:[UIImage imageNamed:@"app"]];
    self.iconview.frame = self.statusFrame.iconviewF;
    
//    [self.vipview setImage:[UIImage imageNamed:@"app"]];
//    self.vipview.frame  = self.statusFrame.vipviewF;
    
//    [self.photoview setImage:[UIImage imageNamed:@"app"]];
//    self.photoview.frame  = self.statusFrame.photoviewF;
    // 名字
    self.nameLable.text = user.name;
    self.nameLable.frame = self.statusFrame.nameLableF;
    //时间
    self.timeLable.text = status.created_at;
    self.timeLable.frame = self.statusFrame.timeLableF;
    
    self.sourceLable.text = status.source;
    self.sourceLable.frame = self.statusFrame.sourceLableF;
    
    self.contentLable.text = status.text;
    self.contentLable.frame = self.statusFrame.contentLableF;
    
    
    
}

-(void)setRetweetsData
{
    
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self)
    {
        // 1 添加原创微博的内部子控件
        [self setupOriginalSubviews];
        
//        [self setupRetweetsubviews];
        
//        [self setupStatusToolBar];
        
    }
    
    return self;
}

- (void)awakeFromNib {
    // Initialization code
}


-(void)setupOriginalSubviews
{
    UIImageView *topView =[[UIImageView alloc] init];
    [self.contentView addSubview:topView];
    self.topview = topView;
    
    UIImageView *iconView =[[UIImageView alloc] init];
    [self.topview addSubview:iconView];
    self.iconview = iconView;
    
//    UIImageView *photoView =[[UIImageView alloc] init];
//    [self.topview addSubview:photoView];
//    self.photoview = photoView;
    
    UILabel *nameLabel = [[UILabel alloc] init];
    [self.topview addSubview:nameLabel];
    nameLabel.font = JOStatusNameFont;
    self.nameLable = nameLabel;
    
    UILabel *timeLable = [[UILabel alloc] init];
    timeLable.font = JOStatusNameFont;
    [self.topview addSubview:timeLable];
    self.timeLable = timeLable;

    UILabel *sourceLable = [[UILabel alloc] init];
    sourceLable.font = JOStatusNameFont;
    [self.topview addSubview:sourceLable];
    self.sourceLable =sourceLable;
 
    UILabel *contentLable = [[UILabel alloc] init];
    contentLable.font = JOStatusNameFont;
    contentLable.numberOfLines = 0 ; // 显示多行
    [self.topview addSubview:contentLable];
    self.contentLable = contentLable;

}

-(void)setupRetweetsubviews
{
    UIImageView *retweetView =[[UIImageView alloc] init];
    [self.topview addSubview:retweetView];
    self.retweetView = retweetView;
    
    UILabel *retweetNameLabel = [[UILabel alloc] init];
    [self.topview addSubview:retweetNameLabel];
    self.retweetNameLabel = retweetNameLabel;
    
    // 名字
    UILabel *retweetContentLabel =[[UILabel alloc] init];
    [self.topview addSubview:retweetContentLabel];
    self.retweetContentLabel = retweetContentLabel;
    
    //时间
    UIImageView *retweetPhotoView =[[UIImageView alloc] init];
    [self.topview addSubview:retweetPhotoView];
    self.retweetPhotoView = retweetPhotoView;
}

-(void)setupStatusToolBar
{
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
